Repository navigation
fix(studio): a second sealed resize of a scaled layer no longer jumps and saves the jump - #8565
Conversation
Edit accuracy: accurate 273 (base branch 271), smooth 58 of thoseThe gate passes. Newly passing (2)
Not banked yet, reported and not gated (bank a full-grid run's baseline.json) (2)
Quarantined, measured but not gated (0) |
…e reruns its script
…tand-in, one re-read per rerun
… an unsealed one does
vanceingalls
left a comment
There was a problem hiding this comment.
Traced the three causes at 679abcc: the box-size clear now runs once in finalizeScaleResizeCommit after the commit persists, on draftEl ?? selection.element (correctOnElement has no other caller); rereadGsapSnapshot drops held values and re-reads after a sealed rerun lands and on undo, and the ordered port keeps the read after the write; gsapOwnsPosition is decided at the press and falls back to getOffsetDragGsap without a frame start, so unsealed is unchanged. Fix lines name one test per cause, and the bench shows sealed matching unsealed (158 px to under 0.3 px). Approving.
Small follow-up: the early return in finalize (!scaleDraftDropPoint || !selector) clears only if (draftEl), so a sealed resize with no drop point can still leave the dropped size on the stand-in; use draftEl ?? selection.element there too. Merge this first, then restack #8587/#8598.
What
In a sealed preview, a second resize of a layer that has its own scale now starts from the size the first resize saved. Before, it started from the first drop's size on top of the saved scale: the layer jumped as the drag began, and the jump was saved. An unsealed preview was never affected.
Why
Three things left state behind after the first sealed resize of a scaled layer, and the second resize built on each:
correctOnElement); a sealed drop measures over the frame's port instead (correctOnFrame) and never reached it. The next gesture read that size as its start (domEditOverlayStartGesture.ts,readStudioBoxSize).gsapFrameSnapshot.ts), and read again only after a seek, a reload or an undo. A save reruns the frame's script in place at the same playhead, so the second resize read the scale from before the first save (1.125 instead of 1.542) and saved 1.43 where unsealed saves 1.96.manualOffsetDrag.ts,endManualOffsetDragMembers), but it asked the element's own page for GSAP, which a sealed stand-in doesn't have. The second gesture counted from the leftover offset, and the file saved x 84.392 where unsealed saves 39.706.Related work
Found while checking sealed resize parity; no bench case did two resizes in a row before this one.
How
packages/studio/src/hooks/gsapResizeIntercept.ts: the scale finalize clears the box size once, for both routes, on the element the next resize reads its size from: the frame's own element unsealed, Studio's stand-in sealed.packages/studio/src/hooks/scaleDropPoint.ts:correctOnElementno longer clears it, so there is one clear.packages/studio/src/hooks/gsapFrameSnapshot.ts:rereadGsapSnapshotdrops the held values and reads the frame again; the undo handler uses it, andpackages/studio/src/utils/gsapSoftReload.tscalls it when a sealed rerun lands.packages/studio/src/components/editor/manualOffsetDrag.ts: whether GSAP owns the position is decided once at the press, from the same read asplainTranslate(the frame's gesture start, sealed), and the drag's end uses it, so a sealed drag runs the same clear as an unsealed one.seqscaletwice, two resizes in a row on a GSAP-scaled box, root and nested, with its timings and the grid's counts.Test plan
fails without the fix:
packages/studio/src/hooks/gsapResizeDropPoint.test.ts, "lands on the drop point in a sealed preview, measured by the frame, and leaves no box size behind": on main the stand-in keeps the dropped 900 x 360 px size after the save.packages/studio/src/utils/gsapSoftReload.sealed.test.ts, "reads the frame's GSAP values again once a saved script reruns in place": without the re-read Studio still reads scaleX 1.125 after the frame reran at 1.542. It also checks the re-read goes once per landed rerun and not after a refused one.packages/studio/src/components/editor/gsapMoveSealedPreview.test.ts, "leaves no Studio offset on the stand-in once a sealed drag ends on GSAP's route": without the fix the stand-in keeps--hf-studio-offset-x: 20px.Two existing tests list the requests Studio sends the frame:
gsapUndoRestore.sealed.test.tsanduseGsapScriptCommits.sealed.test.ts. A landed rerun now also sends agsap-snapshotread, so both leave that one kind out of their lists; every other request they checked is still checked, in the same order.With the fix, on a Linux machine: the 18 test files that build or end an offset drag or soft-reload a sealed frame, plus
gsapResizeDropPoint.test.ts, pass three runs in a row (373 tests), and the bench's own tests pass three runs in a row (126). The push gate's named and covering files (101), Studiotsc, Fallow and pre-push are clean.Bench
Edit-accuracy bench on a Linux machine,
seqscaletwiceroot and nested, two runs per mode, the same bench throughout, this branch with main merged in. Worst case, in px:The saved files after the second resize, both runs the same:
On main sealed saved x 84.392, y 59.594; with the size fix alone, scale 1.43. Before main was merged in, the sealed position was 0.07 px off unsealed's: the sealed drag's corners on a layer with its own scale, which #8562 fixed on main.
No visible change
Sealed previews are off by default, so nothing changes for anyone yet. With them on, a scaled layer resized twice keeps the size it was given.